package com.oocl.scan.global;

import com.oocl.scan.dao.ConstantDao;
import com.oocl.scan.dao.impl.ConstantDaoImpl;
import com.oocl.scan.io.FileScanner;
import com.oocl.scan.model.Constant;
import com.oocl.scan.producer.ConstantProducer;
import com.oocl.scan.store.ConstantStore;
import java.util.Arrays;

public class UpdateGlobalStore {

  private void updateConstant(){
    ConstantDao dao = new ConstantDaoImpl();
    Constant constant;
    while((constant=ConstantStore.getInstance().poll())!=null){
      dao.add(constant);
    }
  }

  public void update(String path){
    FileScanner scanner = new FileScanner(Arrays.asList(new ConstantProducer()));
    scanner.scan(path);
    updateConstant();
  }
}
